import React, { useState, useEffect } from "react";
import { collectGet } from "../../api/user";
import Course from "../../components/course";
import CourseList from "../../components/course/CourseList";
import CustomNav from "../../components/CoustomNavBar";
import { useUserStore } from "../../store/user";

type Props = {};

export default function Collect({}: Props) {
  const [list, setList] = useState([]);
  const { userInfo } = useUserStore((state) => state);
  useEffect(() => {
    if (userInfo) {
      collectGet(userInfo.objectId).then((res) => {
        console.log(res);
        setList(res.data.results);
      });
    }
  }, []);
  return (
    <div>
      <CustomNav title="个人收藏" />
      <CourseList list={list} idKey="courseid" />
    </div>
  );
}
